﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace CustomControls.ImageButton
{
    public partial class TooleButton : UserControl
    {
        public TooleButton()
        {
            InitializeComponent();
            this.button.Click += Button_Click;
        }
        public ICommand Command { get; set; }
        int countStepe = 0;
        /// <summary>
        /// 点击时
        /// </summary>
        public event EventHandler Click;
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (countStepe == 0)
            {
                countStepe++;
                this.IsBtSelected = true;
            }
            else
            {
                countStepe = 0;
                this.IsBtSelected = false;
            }
            this.Click?.Invoke(this, new EventArgs());
        }


        /// <summary>
        /// 文本显示
        /// </summary>
        public string BtContent
        {
            get { return (string)GetValue(BtContentProperty); }
            set { SetValue(BtContentProperty, value); }
        }

        /// <summary>
        /// 默认颜色
        /// </summary>
        public SolidColorBrush FontNomalColor
        {
            get { return (SolidColorBrush)GetValue(FontNomalColorProperty); }
            set { SetValue(FontNomalColorProperty, value); }
        }



        public FontFamily BtFontFamily
        {
            get { return (FontFamily)GetValue(BtFontFamilyProperty); }
            set { SetValue(BtFontFamilyProperty, value); }
        }

        public static readonly DependencyProperty BtFontFamilyProperty =
            DependencyProperty.Register("BtFontFamily", typeof(FontFamily), typeof(TooleButton), new PropertyMetadata(new FontFamily("微软雅黑")));



        /// <summary>
        /// 是否被选中
        /// </summary>
        public bool IsBtSelected
        {
            get { return (bool)GetValue(IsBtSelectedProperty); }
            set { SetValue(IsBtSelectedProperty, value); }
        }

        /// <summary>
        /// 经过
        /// </summary>
        public SolidColorBrush FondOverColor
        {
            get { return (SolidColorBrush)GetValue(FondOverColorProperty); }
            set { SetValue(FondOverColorProperty, value); }
        }

        /// <summary>
        /// 选中
        /// </summary>
        public SolidColorBrush FondSelectColor
        {
            get { return (SolidColorBrush)GetValue(FondSelectColorProperty); }
            set { SetValue(FondSelectColorProperty, value); }
        }

        /// <summary>
        /// 禁用
        /// </summary>
        public SolidColorBrush FondDisColor
        {
            get { return (SolidColorBrush)GetValue(FondDisColorProperty); }
            set { SetValue(FondDisColorProperty, value); }
        }

        /// <summary>
        /// 内容
        /// </summary>
        public string TextContent
        {
            get { return (string)GetValue(TextContentProperty); }
            set { SetValue(TextContentProperty, value); }
        }

        /// <summary>
        /// 文本字体大小
        /// </summary>
        public int TextFontSize
        {
            get { return (int)GetValue(TextFontSizeProperty); }
            set { SetValue(TextFontSizeProperty, value); }
        }

        /// <summary>
        /// 文本位置
        /// </summary>
        public string TextMargin
        {
            get { return (string)GetValue(TextMarginProperty); }
            set { SetValue(TextMarginProperty, value); }
        }

        #region 属性注册
        public static readonly DependencyProperty TextMarginProperty =
           DependencyProperty.Register("TextMargin", typeof(string), typeof(TooleButton), new PropertyMetadata("0"));
        public static readonly DependencyProperty TextFontSizeProperty =
    DependencyProperty.Register("TextFontSize", typeof(int), typeof(TooleButton), new PropertyMetadata(12));
        public static readonly DependencyProperty TextContentProperty =
           DependencyProperty.Register("TextContent", typeof(string), typeof(TooleButton), new PropertyMetadata(""));
        public static readonly DependencyProperty BtContentProperty =
        DependencyProperty.Register("BtContent", typeof(string), typeof(TooleButton), new PropertyMetadata(""));
        public static readonly DependencyProperty IsBtSelectedProperty =
            DependencyProperty.Register("IsBtSelected", typeof(bool), typeof(TooleButton), new PropertyMetadata(false));
        public static readonly DependencyProperty FondOverColorProperty =
        DependencyProperty.Register("FondOverColor", typeof(SolidColorBrush), typeof(TooleButton), new PropertyMetadata(new SolidColorBrush(Colors.White)));
        public static readonly DependencyProperty FondSelectColorProperty =
       DependencyProperty.Register("FondSelectColor", typeof(SolidColorBrush), typeof(TooleButton), new PropertyMetadata(new SolidColorBrush(Colors.White)));
        public static readonly DependencyProperty FondDisColorProperty =
          DependencyProperty.Register("FondDisColor", typeof(SolidColorBrush), typeof(TooleButton), new PropertyMetadata(new SolidColorBrush(Colors.White)));
        public static readonly DependencyProperty FontNomalColorProperty =
            DependencyProperty.Register("FontNomalColor", typeof(SolidColorBrush), typeof(TooleButton), new PropertyMetadata(new SolidColorBrush(Colors.White)));
        #endregion

    }
}